package sala.commonmovie.bottommenu 
{
	import flash.display.MovieClip;
	import sala.events.BottomMenuEvent; 
	import flash.events.MouseEvent; 
	import sala.LanguageManager; 
	/**
	 * ...
	 * @author zacess
	 */
	public class BottomMenuContainer extends MovieClip
	{
		public var aboutusMc:BottomMenuItem; 
		public var servicesMc:BottomMenuItem; 
		public var castingMc:BottomMenuItem; 
		public var galleryMc:BottomMenuItem; 
		public var contactMc:BottomMenuItem; 
		
		public var engLangMc:MovieClip; 
		public var viLangMc:MovieClip; 
		public var activeLanguageItem:MovieClip; 
		
		public var currentLanguage:MovieClip; 
		
		public var activeItem:BottomMenuItem; 
		
		public function BottomMenuContainer() 
		{
			engLangMc.buttonMode = true; 
			viLangMc.buttonMode = true; 
			aboutusMc.active = true;
			
			activeLanguageItem = engLangMc; 
			
			activeItem = aboutusMc; 
			
			currentLanguage = engLangMc; 
			
			this.addEventListener(BottomMenuEvent.MENU_BUTON_CLICK, bottomMenuItemHdl); 
			engLangMc.addEventListener(MouseEvent.CLICK, englishButtonClickHdl); 
			viLangMc.addEventListener(MouseEvent.CLICK, vietButtonClickHdl); 
		}
		
		private function vietButtonClickHdl(e:MouseEvent):void 
		{
			//if (activeLanguageItem != MovieClip(e.target)) {
				//trace("viet button clicked"); 
				activeLanguageItem = MovieClip(e.target); 
				var evt:BottomMenuEvent = new BottomMenuEvent(BottomMenuEvent.VIET_BUTTON_CLICK); 
				dispatchEvent(evt); 
				activeLanguageItem = null; 
			//}
		}
		
		private function englishButtonClickHdl(e:MouseEvent):void 
		{
			//if (activeLanguageItem != MovieClip(e.target)) {
				//trace("eng button clicked"); 
				activeLanguageItem = MovieClip(e.target); 
				var evt:BottomMenuEvent = new BottomMenuEvent(BottomMenuEvent.ENG_BUTTON_CLICK); 
				dispatchEvent(evt); 
				activeLanguageItem = null; 
			//}
		}
		
		private function bottomMenuItemHdl(e:BottomMenuEvent):void 
		{
			activeItem.active = false;
			activeItem = BottomMenuItem(e.target);
			activeItem.active = true;
		}
		
		public function setText():void
		{
			aboutusMc.Tf.text = LanguageManager.getText("ABOUT_US_ITEM"); 
			servicesMc.Tf.text = LanguageManager.getText("SERVICES_ITEM"); 
			castingMc.Tf.text = LanguageManager.getText("CASTING_ITEM"); 
			galleryMc.Tf.text = LanguageManager.getText("GALLERY_ITEM"); 
			contactMc.Tf.text = LanguageManager.getText("CONTACT_ITEM"); 
		}
				
	}

}